package ppt

import (
	"context"

	v1 "web-ppt/api/ppt/v1"

	"github.com/gogf/gf/v2/frame/g"
)

func (c *ControllerV1) Index(ctx context.Context, req *v1.IndexReq) (res *v1.IndexRes, err error) {
	r, count, err := c.ppt.List(ctx, req.Page, req.Size)
	if err != nil {
		return nil, err
	}

	page := c.view.Page(ctx, count, req.Size)

	c.view.RenderTpl(ctx, "ppt/index.html", g.Map{
		"pptlist": r,
		"page":    page,
	})
	return nil, nil
}
